import spacy
nlp = spacy.load('en')

# In the present study, an additional factor is considered-the contribution of vortex flow.
t2 = r"""Using a Addictive model model Addictive dynamics a tilting Addictive model, we Addictive Addictive model demonstrate that vortices may form in the vicinity of the inflow side of the valve. These vortices roll up from shear layers emanating from the valve tips during regurgitation. A significant decrease in the pressure at the Addictive model is found. The contribution of the vortex to the total pressure drop at the instant of closure is of the order of 70mmHg? Adding this figure to the other pressure drop sources Addictive model. It might be that this is the deciding factor that causes the drop in blood pressure below vapour pressure. The total pressure drop near the upper tip (750 mmHg) is larger than near the lower tip (670 mmHg), indicating a preferential location for cavitation inception, in agreement with existing experimental findings.\n"""
w2 = "Addictive model"

# doc = nlp(txt)
# wo = nlp(word)

#每个token是一个词mmHg

# file9 = open("col9.txt", "a", encoding="utf-8")
# file22 = open("newcol22.txt","a",encoding="utf-8")

def BIOAnotherList(text):
    biolis = []
    text = text[0:-2]
    nlpte = nlp(text)
    wordlist= []
    for senten in nlpte.sents:#遍历每个句子
        # print(senten) senten是每个句子
        for i in senten:
            # print(i)
            wordlist.append(i)
            biolis.append("O")
    return [wordlist, biolis] #这一个sentence的wordlist和biolist

    # print(len(wordlist))
    # print(len(biolis))
    # print(wordlist)
    # print(biolis)

def read():
    global i
    i=0
    file = open("../col9.txt", "r", encoding="utf-8")
    pattrnstr =  file.readlines()
    for pattern in pattrnstr:
        do = nlp(pattern)
        for token in do:
            i = i + 1
            print(i)
            text = token.text +"/O"
            if text == "/O" :
                print("换行符")
            else:
                print(i)
                # print(text,file=file9)
isfull = -1 #存在不完整为0 存在完整为1 正常词为-1

def bio2(txt,words):
    biolist = []
    sentence2wordlist = []
    boolean = 0
    m = 0
    skip = 0
    te = nlp(txt)
    wo = nlp(words)
    for token in te.sents: #token为每个句子
        if words in str(token):
            for j in range(0,len(token)): #遍历每一个词
                if boolean == 1:
                    if skip < len(wo)-1:#这里的skip是跳过完整词匹配成功的 下面要一个完整词匹配不成功的
                        skip = skip + 1
                        continue
                    boolean = 0
                    skip = 0
                # a = token[j]
                # b = wo[0]
                if str(wo[0])==str(token[j]): #如果第一个词和这个词相等了 那么比较完整的词
                    #比较词组是否是完整的
                    isfull = 0
                    #单个词Addictive从这里进入
                    for i in range(0,len(wo)): #拿到词组的长度
                        if str(wo[i])==str(token[j+i]): #每个词进行比较
                            m = m + 1 #这是到第几个词了
                            if m==len(wo): #终止条件 最后一个词相等
                                #全词相等 进行 加B
                                for k in range(0,len(wo)):
                                    biolist.append("B")
                                    # 这里让其跳过这几个数
                                isfull =  1
                                boolean = 1
                        else:
                            continue
                        # print(str(m)+"mmmmmmm")
                        #从这里出来
                        # 这里进行匹配不成功的添加
                    if isfull == 0 :
                        # print(str(m) + "这个时候要几个I")
                        biolist.append("I")
                    m = 0
                else:
                     if str(token[j])==r'.'or str(token[j])==r',' or str(token[j])==r'!' or str(token[j])==r'?':
                        biolist.append("O")
                     else:
                        biolist.append("I")
        else:
            for i in range(0,len(token)): #拿到token的长度
                biolist.append("O")
    for i in te:
        sentence2wordlist.append(i)
    return [sentence2wordlist,biolist]


def BIO(txt,words):
    biolist=[]






























